package Project.QuickHit;


import java.util.Random;

public class Game {
    Player player;
    boolean flag=true;

    public Game() {
    }

    public Game(Player player) {
        this.player = player;
    }

    public Player getPlayer() {
        return player;
    }

    public void setPlayer(Player player) {
        this.player = player;
    }

    public String printStr(){
        StringBuilder buffer=new StringBuilder();
        int strLength= LevelParam.levels[player.getLevelNo()].getStrLength();
        Random random=new Random();
        for (int i = 0; i <strLength ; i++) {
            int rand=random.nextInt(strLength);
            switch (rand) {
                case 0:
                    buffer.append("q");
                    break;
                case 1:
                    buffer.append("w");
                    break;
                case 3:
                    buffer.append("e");
                case 4:
                    buffer.append("r");
            }
    }
       return String.valueOf(buffer);

    }
    public void printResult(String out,String in){

        if (in.equals(out)) {
       if(player.getElapsedTime()>LevelParam.levels[player.getLevelNo()-1].getTimeLimit()){
           System.out.println("您输入太慢啦，退出游戏！");
           this.flag=false;

       }else{
           player.setCurrScore(player.getCurrScore()+
                   LevelParam.levels[player.getLevelNo()-1].getPerScore());
           System.out.println("您的积分："+player.getCurrScore()+
                   "您的级别："+player.getLevelNo()+"已用时间："+player.getElapsedTime());
       }
        }
        if(!in.equals(out)){
            System.out.println("输入错误，退出游戏！");
            this.flag=false;

        }
    }
}
